package com.cskaoyan;

import com.cskaoyan.connectionpool.MyConnectionPool;
import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {

    public static void main(String[] args) throws SQLException {

        // 获取连接
        Connection connection = MyConnectionPool.getConnection();

        connection.close();

        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery("select * from account");

        while (resultSet.next()) {
            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            System.out.println("id:" + id + ", name:" + name);
        }

        // 关闭资源
        JDBCUtils.closeResources(null,statement,resultSet);

        // 返回连接
        MyConnectionPool.returnConnection(connection);

    }
}
